#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package}.convert;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import ${package}.api.dto.DemoDto;
import ${package}.domain.DemoDo;
import com.ruoyi.common.core.wrapper.BaseWrapper;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
/**
 * 对象转换类
 *
 * @author ruoyi
 * @date 2022-02-15 10:59:29
 */
@Mapper
public interface DemoConverter {
    DemoConverter INSTANCE = Mappers.getMapper(DemoConverter.class);
    public static LambdaQueryWrapper<DemoDo> buildWrapper(DemoDto demoDto) {
        if (demoDto == null) {
            return new LambdaQueryWrapper<>();
        }
        LambdaQueryWrapper<DemoDo> lambdaQueryWrapper = new LambdaQueryWrapper<>(DemoDo.class);
        BaseWrapper<DemoDo> baseWrapper = new BaseWrapper<>();
        baseWrapper.buildBaseWrapper(lambdaQueryWrapper, demoDto);
        if(null != demoDto.getId()){
            lambdaQueryWrapper.eq(DemoDo::getId, demoDto.getId());
        }
        if (StringUtils.isNotBlank(demoDto.getUserCode())) {
            lambdaQueryWrapper.eq(DemoDo::getUserCode, demoDto.getUserCode());
        }
        if (StringUtils.isNotBlank(demoDto.getUserName())) {
            lambdaQueryWrapper.likeRight(DemoDo::getUserName, demoDto.getUserName());
        }
        return lambdaQueryWrapper;
    }

    /**
     * doList2DtoList
     *
     * @param list
     * @return
     */
    List<DemoDto> doList2DtoList(List<DemoDo> list);

    /**
     * do2Dto
     *
     * @param demoDo
     * @return
     */
    DemoDto do2Dto(DemoDo demoDo);

    /**
     * dto2Do
     *
     * @param demoDto
     * @return
     */
    DemoDo dto2Do(DemoDto demoDto);

    /**
     * dtoList2DoList
     *
     * @param dtoList
     * @return
     */
    List<DemoDo> dtoList2DoList(List<DemoDto> dtoList);
}
